<template>
    <Teleport v-if="!!userList.length" to="body">
        <div class="compare-card">
            <div class="compare-left">
                <Avatar :username="userList[0].username" :avatar="userList[0].avatar"/>
            </div>
            <div class="pk-text">PK</div>
            <div class="compare-right">
                <Avatar :username="userList[1].username" :avatar="userList[1].avatar"/>
            </div>
        </div>
    </Teleport>
</template>

<script setup>
import { ref} from 'vue'
import Avatar from './Avatar.vue';

const props = defineProps([])
const userList = ref([]);
defineExpose({
    compare: () => {
        userList.value = [
            { username: '张三', age: 18,avatar:'src/assets/image/avatar.png' },
            { username: '李四', age: 19,avatar:'src/assets/image/avatar.png' },
        ]
    }
})
</script>

<style scoped lang="less">
.compare-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    width: 100%;
    z-index: 999;
    background-color: rgba(0,0,0,0.4);
    .compare-left,
    .compare-right{
        flex:1;
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: center;
        justify-content: center;
        padding: 20px;
        color: aliceblue;
        .avatar{
            width: 80px;
            height: 80px;
        }
    }
    .compare-left{
    }
    .compare-right{
    }
    .pk-text{
        font-size: 100px;
        color: aliceblue;
    }
}
</style>